using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Data.SqlClient;

/// <summary>
/// Summary description for PetCategory
/// </summary>
public class PetCategoryDAO:DBConnection
{
    #region sql command
    string SQL_SELECT_ID = "";
    string SQL_SELECT_ALL = "select * from PetCategory";
    string SQL_INSERT = "insert into PetCategory ([Name], ImageURL) values(@name, @imageURL)";
    string SQL_UPDATE = "update PetCategory set [Name]=@name, ImageURL=@imageURL";
    string SQL_DELETE = "delete from Petcategory where PetCategoryID=@id";
    #endregion

    #region fields
    #endregion

    #region constructors
    #endregion

    #region properties
    #endregion

    #region methods
    public IList<PetCategory> GetAllCategories()
    {
        IList<PetCategory> list = new List<PetCategory>();
        try
        {
            SqlCommand command = new SqlCommand(SQL_SELECT_ALL, conn);
            if (Connect())
            {
                SqlDataReader dr = command.ExecuteReader();
                while (dr.Read())
                {
                    PetCategory cate = new PetCategory();
                    cate.ID = dr.GetInt32(0);
                    cate.Name = dr.GetString(1);
                    list.Add(cate);
                }
                Disconnect();
            }
        }
        catch (SqlException ex) { }
        return list;
    }
    public int Insert(Pet pet)
    {
        int effectedRows = 0;
        try
        {
            SqlCommand command = new SqlCommand(SQL_INSERT, conn);
           // command.Parameters.AddWithValue("@name");
          //  command.Parameters.AddWithValue("imageURL");
            if (Connect())
            {
                effectedRows = command.ExecuteNonQuery();
                Disconnect();
            }
        }
        catch (SqlException ex) { }
        catch (Exception ex) { }
        return effectedRows;
    }
    #endregion
}
